package com.itboye.textileexpes.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.ColletionFenyeBeans;
import com.itboye.textileexpes.beans.GoodsBean;
import com.itboye.textileexpes.interfaces.ICollocetion;
import com.itboye.textileexpes.interfaces.IGoods;
import com.itboye.textileexpes.repository.CollectionRepository;
import com.itboye.textileexpes.repository.GoodsRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

public class ColloctionPresenter extends BasePresenter implements
		ICollocetion<ColletionFenyeBeans> {
	public static final String ColloctFenye_success = MainPresenter.class
			.getName() + "_ColloctFenye_success";
	public static final String ColloctFenye_fail = MainPresenter.class
			.getName() + "_ColloctFenye_fail";
	public static final String ColloctDelete_success = MainPresenter.class
			.getName() + "_ColloctDelete_success";
	public static final String ColloctDelete_fail = MainPresenter.class
			.getName() + "_ColloctDelete_fail";
	public static final String ColloctTop_success = MainPresenter.class
			.getName() + "_ColloctTop_success";
	public static final String ColloctTop_fail = MainPresenter.class.getName()
			+ "_ColloctTop_fail";
	public static final String ColloctCate_success = MainPresenter.class
			.getName() + "_ColloctCate_success";
	public static final String ColloctCate_fail = MainPresenter.class.getName()
			+ "_ColloctTop_fail";
	public static final String ColloctAdd_success = MainPresenter.class
			.getName() + "_ColloctAdd_success";
	public static final String ColloctAdd_fail = MainPresenter.class.getName()
			+ "_ColloctAdd_fail";

	public static final String ColloctOrder_fail = MainPresenter.class
			.getName() + "_ColloctOrder_fail";
	public static final String ColloctOrder_success = MainPresenter.class
			.getName() + "_ColloctAdd_success";

	public ColloctionPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctAdd_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctAdd_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.add(model);
	}

	@Override
	public void delete(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctDelete_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctDelete_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.delete(model);
	}

	@Override
	public void update(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctTop_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctTop_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.update(model);
	}

	@Override
	public void getInfo(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<ColletionFenyeBeans> query(ColletionFenyeBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void FenYeQuery(String uid, String page_size, String page_index,
			String keyword, String cate_id) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctFenye_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctFenye_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.FenYeQuery(uid, page_size, page_index, keyword, cate_id);
	}

	@Override
	public void CollectionCateType(String uid) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctCate_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctCate_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.CollectionCateType(uid);
	}

	@Override
	public void CollectOrder(String uid, String pid) {
		// TODO Auto-generated method stub
		ICollocetion<ColletionFenyeBeans> colloct = new CollectionRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctOrder_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ColloctOrder_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		colloct.CollectOrder(uid, pid);
	}

}
